<template>
  <view>
    <nav-bar :page-title="contentData.title"/>
    <view class="margin-30">
      <u-parse :content="contentData.content" :tagStyle="style"></u-parse>
      <view style="height: 100rpx;"/>
    </view>
  </view>
</template>

<script lang="ts">
import Vue from 'vue';
import NavBar from '@/components/nav-bar/nav-bar.vue';

export default Vue.extend({
  name: "analysis",
  components: {NavBar},
  data() {
    return {
      contentData: {},
      style: {
        // 字符串的形式
        div: 'font-size:40rpx;font-weight: bold'
      }
    };
  },
  onLoad(query?: AnyObject) {
    console.log('analysis.vue', query.param)
    this.fetchContent(query.param)
  },
  methods: {
    fetchContent(param: string) {
      uni.showLoading({title: '加载中...'})
      uni.request({
        url: `https://jieling.ailogo.top/index.php?do=articleone&biaos=${param}`, // 请求的 URL
        method: 'GET', // 请求方法
        success: (res: any) => {
          const {code, data} = res.data
          // 请求成功的回调
          if (code === 1) {
            this.contentData = data
            uni.hideLoading()
          }
        },
        fail: (err) => {
          // 请求失败的回调
          console.error('请求失败', err);
        }
      });

    }
  },
  created() {
    this.fetchContent();
  }
});
</script>

<style scoped lang="scss">
.margin-30 {
  margin: 30rpx;
}
</style>
